<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>登录</title>
	</head>
	<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
	</script>
	<script>

		//本地地址	
		var localhostUrl="http://localhost:8080/";
		//服务器地址
		//var localhostUrl="http://101.42.48.35/"
		$(document).ready(function() {
			$("#register").click(function() {
				var account=document.getElementById("root").value;
			    var pwd=document.getElementById("pwd").value;
				///获取角色信息
				$.ajax({
					url:  localhostUrl+"xiezhewan/loginByUserInfo",
					type: "POST",
					contentType: "application/json;charset=UTF-8",
					dataType: "json",
					data: JSON.stringify({
						"user_account": account,
						"user_pwd": pwd 
					}),
					success: function(result) {
						console.log(result);
						var json= JSON.parse(JSON.stringify(result));
						if(json.code=="9999"){
							alert( json.data);
						}else{
							alert("登陆成功...")
							///$("#div1").hide();
							///把属性存在本地内存
							// window.localStorage.setItem('user_HP', json.data.user_HP);
							// window.localStorage.setItem('user_MP', json.data.user_MP);
							// window.localStorage.setItem('user_M', json.data.user_M);
							// window.localStorage.setItem('user_A', json.data.user_A);
							// window.localStorage.setItem('user_DF', json.data.user_DF);
							// window.localStorage.setItem('user_property', json.data.user_property);
							// window.localStorage.setItem('user_lv', json.data.user_lv);
							// window.localStorage.setItem('user_scope', json.data.user_scope);
							// window.localStorage.setItem('user_ex', json.data.user_ex);
							// window.localStorage.setItem('user_upex', json.data.user_upex);
							window.localStorage.setItem("user_account",json.data.user_account);
							// if( json.data.user_profession==1){
							// 	window.localStorage.setItem('user_profession', "战士");
							// }else{
							// 	window.localStorage.setItem('user_profession', "法师");
							// }	
																									  
						window.location.href='Combat.html'
						}		
					 }
				});
				
				
			
			});
			
			$("#fanhui").click(function() {
				  window.location.href='register.html'
			});
			 
		});
		
		
	</script>


		

	<body>
		<div id="div1">
			<ul>账号：<input type="text" id="root"></input></ul>
			<ul>密码：<input type="text" id="pwd"></input></ul>
			<ul> <button id="register">登录</button> <button id="fanhui">前往注册</button></ul>
		</div>



	</body>

	</script>
</html>
